// 创建scrpt标签，插入到当前网站中
function insertScript (src) {
  const scriptTag = document.createElement('script')
  scriptTag.src = src
  document.body.appendChild(scriptTag)
}

// chrome.storage.local.get(['publicScript', 'customScript'], (result) => {
//   console.debug('%c  result', 'font-size:30px;', result)
//   insertScript(result.publicScript)
//   insertScript(result.customScript)
// })

/*
vue3
const vuejs = chrome.runtime.getURL('webScript/pulicScript/vue3.global.js')
const elementPlusJs = chrome.runtime.getURL('webScript/pulicScript/element-plus/element-plus.js')
insertScript(vuejs)
insertScript(elementPlusJs)
insertScript(httpVueLoader)
// 动态加载CSS文件
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = chrome.runtime.getURL('webScript/pulicScript/element-plus/index.css')
document.head.appendChild(link)
*/
const vuejs = chrome.runtime.getURL('webScript/pulicScript/vue2.min.js')
const elementPlusJs = chrome.runtime.getURL('webScript/pulicScript/element-ui/index.js')
const httpVueLoader = chrome.runtime.getURL('webScript/pulicScript/httpVueLoader.js')
insertScript(vuejs)
insertScript(elementPlusJs)
insertScript(httpVueLoader)
// 动态加载CSS文件
const link = document.createElement('link')
link.rel = 'stylesheet'
link.href = chrome.runtime.getURL('webScript/pulicScript/element-plus/index.css')
document.head.appendChild(link)

const div = document.createElement('div')
const mainComponentUrl = chrome.runtime.getURL('webScript/pulicScript/components/main.vue')
div.innerHTML = `
  <div id="aaaaaaaa" url="${mainComponentUrl}" >

  </div>
`
document.body.appendChild(div)
const mainJsUrl = 'https://github-youdaxia.github.io/google-plugin-enhance-web/webScript/pulicScript/main.js'
insertScript(mainJsUrl)
